import unittest, sys

sys.path.append( '../lib/')
from Registry import *

class RegisterTestCase(unittest.TestCase):
    def runTest(self):
        reg1 = Register('key1','val1')
        assert reg1.key() == 'key1'
        assert reg1.val() == 'val1'
        reg1.setKey('key1b')
        reg1.setVal('val1b')
        assert reg1.key() == 'key1b'
        assert reg1.val() == 'val1b'
        reg2= Register('key2','val2')
        assert reg2.key() == 'key2'
        assert reg2.val() == 'val2'
        
class RegistryTestCase(unittest.TestCase):
    def runTest(self):
        registry1 = Registry()
        reg1 = Register('key1', 'val1')
        reg2 = Register('key2', 'val2')
        registry1.add( reg1 )
        registry1.add( reg2 )
        assert registry1.val('key1') == 'val1'
        assert registry1.val('key2') == 'val2'
        registry1Length = registry1.dump()
        assert registry1Length == 2
        registry1.remove('key2')
        registry1Length = registry1.dump()
        assert registry1Length == 1

if __name__ == '__main__':
    regTestCase = RegisterTestCase()
    registryTestCase = RegistryTestCase()
    